﻿using System.Data;
using Ue.Qcdz.Domain.ShopArticle;

namespace Ue.Qcdz.Repositories.ShopArticle
{
    public class ShopNewsDataQueryWhereClause : Ue.Infrastructure.RepositoryFramework.Repository.IWhereClause
    {

        private IShopNewsDataQuery shopNewsDataQuery;

        public ShopNewsDataQueryWhereClause(IShopNewsDataQuery dataQuery)
        {
            this.shopNewsDataQuery = dataQuery;
        }

        #region IWhereClause 成员

        public string Clause
        {
            get
            {
                string whereClause = "1=1";
                if (this.shopNewsDataQuery.Status)
                    whereClause += string.Format(" and {0} = 1", ShopNewsFactory.FieldNames.Status);
                if (!string.IsNullOrEmpty(this.shopNewsDataQuery.ShopId))
                    whereClause += string.Format(" and {0} = @{0}", ShopNewsFactory.FieldNames.ShopId);

                return whereClause;
            }
        }

        public System.Data.IDataParameter[] Parameters
        {
            get
            {
                return new IDataParameter[] {
                    SqlServerDriver.Instance.BuildParameter(ShopNewsFactory.FieldNames.ShopId, this.shopNewsDataQuery.ShopId)                 
                };
            }
        }

        #endregion
    }
}
